[Bug] cdpSession.send: Target page, context or browser has been closed #858
Description
Describe the bug
page.goto: Timeout 10000ms exceeded.
Call log:
- navigating to "[SOME_URL]", waiting until "commit"
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
cdpSession.send: Target page, context or browser has been closed
at Object.send ([project_dir]/node_modules/playwright-extra/dist/index.cjs.js:194:46)
I was doing load test of a web server using playwright with playwright-extra to render URLs (once per request).
Load test was done with multiple threads hitting an endpoint.
Every call to an endpoint spawns a separate chromium instance with playwright.
This only started to happen when increasing number of threads to the point where rendering a page with playwright was timing out.
This is critical issue when using playwright in a web service since it crashes it.
Code Snippet
I will create a pull request that fixes the issue.
Versions
System:
OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900K
Memory: 30.08 GB / 31.23 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 18.17.1 - /usr/bin/node
npm: 10.2.4 - /usr/bin/npm
npmPackages:
playwright: ^1.39.0 => 1.40.0
playwright-extra: ^4.3.6 => 4.3.6
puppeteer-extra-plugin-stealth: ^2.11.2 => 2.11.2
Activity
Fix "cdpSession.send: Target page, context or browser has been closed"
netbroom commentedon Feb 27, 2024
This is also impacting default puppeteer/chromium. Getting these errors with the Stealth plugin when using multithreading or scraping multiple websites at once.
it's not tracking when pages and targets are closed properly and not catching all errors when sending data through a CDP session.
When using one browser connecting to multiple pages in different contexts, the stealth plugin crashes fairly often.
Here is one such error, but there are several throughout the code for both Stealth and puppeteer-extra.
lukebelbina commentedon Oct 8, 2024
Running into something similar when in a multi-threaded setup
oubyssf commentedon Dec 10, 2024
I'm having the same problem
rexTexTau commentedon Jan 5, 2025
I've got same results in simple single threaded environment, when a web page opens a popup and then quickly closes it using javascript.